import unittest

from api.py_04_ihrm_login import ihrm_login
from common.py_05_tools import Tools_unitest


class Testihrmlogin(unittest.TestCase):
    def test01_login_ok(self):
        json_data = {"mobile": "13800000002", "password": "123456"}
        resp = ihrm_login.hrm_login(json_data)
        print("登录成功", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, True, 10000, "操作成功")

    def test02_mobile_error(self):
        json_data = {"mobile": "13890000002", "password": "123456"}
        resp = ihrm_login.hrm_login(json_data)
        print("手机号错误", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, False, 20001, "用户名或密码错误")

    def test03_password_error(self):
        json_data = {"mobile": "13800000002", "password": "123456222"}
        resp = ihrm_login.hrm_login(json_data)
        print("密码错误", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, False, 20001, "用户名或密码错误")

    def test04_mobile_weizhuce(self):
        json_data = {"mobile": "13800012341", "password": "123456222"}
        resp = ihrm_login.hrm_login(json_data)
        print("密码错误", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, False, 20001, "用户名或密码错误")

    def test05_mobile_None(self):
        json_data = {"mobile": None, "password": "123456"}
        resp = ihrm_login.hrm_login(json_data)
        print("密码错误", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, False, 20001, "用户名或密码错误")

    def test06_mobile_inculde_err_sinbol(self):
        json_data = {"mobile": "1380000000*$", "password": "123456"}
        resp = ihrm_login.hrm_login(json_data)
        print("密码错误", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, False, 20001, "用户名或密码错误")

    def test07_password_1(self):
        json_data = {"mobile": "13800000002", "password": "1"}
        resp = ihrm_login.hrm_login(json_data)
        print("密码错误", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, False, 20001, "用户名或密码错误")

    def test08_more_parm(self):
        json_data = {"mobile": "13800000002", "password": "123456", "abc": "123"}
        resp = ihrm_login.hrm_login(json_data)
        print("多参数", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, True, 10000, "操作成功")

    def test09_less_parm(self):
        json_data = {"password": "123456222"}
        resp = ihrm_login.hrm_login(json_data)
        print("密码错误", resp.json())
        Tools_unitest.assert_tools(self, resp, 200, False, 20001, "用户名或密码错误")
